var strBundle;

// retrieves a localized string from the enigmail.properties stringbundle
function geti18nString(aStr)
{
    var restCount = arguments.length - 1;
    if(!strBundle) {
        try
        {
            var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService();
            strBundleService = strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
            strBundle = strBundleService.createBundle("chrome://vanish-thunderbird-extension/locale/vanish.properties");
        }
        catch (ex)
        {
            alert("common.js: Error in instantiating stringBundleService : " + ex);
        }
    }

    if(strBundle)
    {
        try
        {
            if(restCount > 0)
            {
                var subPhrases = new Array();
                for (var i = 1; i < arguments.length; i++)
                {
                    subPhrases.push(arguments[i]);
                }
                return strBundle.formatStringFromName(aStr, subPhrases, subPhrases.length);
            }
            else
            {
                return strBundle.GetStringFromName(aStr);
            }
        } 
        catch (ex)
        {
            alert("common.js: Error in querying stringBundleService for string '"+aStr+"'\n");
        }
    }
    return null;
}